/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkg10608;

/**
 *
 * @author xerxes
 */
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;

public class Main {

    BufferedReader reader;
    StringTokenizer token;

    public static void main(String[] args) throws IOException {
        Main ob = new Main();
        ob.run();

        System.exit(0);
    }
    int N, M;
    int[] root, rank;
    int[] most;

    public void run() throws IOException {
        //reader = new BufferedReader(new FileReader("in.txt"));
        reader = new BufferedReader(new InputStreamReader(System.in) );
        token = new StringTokenizer("");
        int cases = nextInt();
        int i, j;
        for (; cases > 0; --cases) {
            N = nextInt();
            M = nextInt();
            Set();
            for (j = 1; j <= M; ++j) {
                int a, b;
                a = nextInt();
                b = nextInt();
                Union(a, b);
            }
            most = new int[N+50];
            Arrays.fill(most, 0);
            for (i = 0; i <= N; ++i) {
                most[ Find(i)]++;
            }
            int retval = most[1];
            for (i = 0; i <= N; ++i) {
                retval = Math.max(retval, most[i]);
            }
            System.out.println(retval);
        }


    }

    public void Set() {
        root = new int[N+50];
        rank = new int[N+50];
        int i;
        for (i = 0; i <= N; ++i) {
            root[i] = i;
            rank[i] = 0;
        }
    }

    public int Find(int x) {
        if (x != root[x]) {
            root[x] = Find(root[x]);
        }
        return root[x];
    }

    public void Union(int x, int y) {
        int rx = Find(x);
        int ry = Find(y);
        if (rx == ry) {
            return;
        } else if (rank[rx] > rank[ry]) {
            root[ry] = rx;
        } else {
            root[rx] = ry;
        }

        if (rank[rx] == rank[ry]) {
            rank[ry] += 1;
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    String nextToken() throws IOException {
        while (token == null || !token.hasMoreTokens()) {
            String line = reader.readLine();
            token = new StringTokenizer(line);
        }
        return token.nextToken();
    }
}
